package com.home.jsonhelpers;

import java.util.Calendar;
import java.util.TimeZone;

import org.json.JSONException;
import org.json.JSONObject;

import com.home.constants.Consts;
import com.home.rhclient.MainController;

import android.content.Context;
import android.provider.Settings;
import android.provider.Settings.Secure;

public class JsonRequestObject {
	
	private JSONObject jsonObject;
	
	public JsonRequestObject(Context context) {	
		jsonObject=new JSONObject();
		//Add user Id
		try {
			String androidId=Secure.getString(context.getContentResolver(),
                    Secure.ANDROID_ID); 
			jsonObject.put(Consts.USER_ID, androidId);
			Calendar cal=Calendar.getInstance();
			//Add time of request
			cal.setTimeZone(TimeZone.getTimeZone("GMT"));
			jsonObject.put(Consts.CLIENT_TIME, MainController.GetInstance().GetCurrentDate().getTime());
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	public void put(String key,Object value) throws JSONException
	{
		jsonObject.put(key, value);
	}
	
	
	public String toString()
	{
		return jsonObject.toString();
	}
	
	public JSONObject getJsonObject()
	{
		return jsonObject;
	}

}
